package cate.game.role.bag.storehouse.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBBag;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@ClientMsg(title = "道具提取出仓库 の 请求")
public class PropStoreHouseTakeOutReq implements MsgInput {
    @NoteField(value = "物品大类")
    public byte type;

    @NoteField(value = "物品唯一ID", detail = "传了唯一id后 模板id就不用传了")
    public String uid;

    @NoteField(value = "模板ID")
    public int tid;

    @NoteField(value = "提取数量")
    public int num;

    @Override
    public MsgConfig conf() {
        return MsgIdBBag.PROP_TAKE_OUT_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        if (StringUtils.isBlank(uid)) {
            // 根据tid来使用
            cc.getRole().getBag().takeOutByTid(type, tid, num);
        } else {
            // 根据idHex来使用
            cc.getRole().getBag().takeOutByUid(type,uid);
        }
    }
}
